#include <iostream>
#include <vector>

using namespace std;

class File {
protected:
    string fname;
public:
    virtual void display(int dept) = 0;
};

class TxtFile : public File{
public:
    TxtFile(string name) {
        fname = name;
    }
    void display(int dept) {
        for (int i=0; i<dept; i++) {
            cout << "-";
        }
        cout << fname << endl;
    }
};

class MovFile : public File{
public:
    MovFile(string name) {
        fname = name;
    }
    void display(int dept) {
        for (int i=0; i<dept; i++) {
            cout << "-";
        }
        cout << fname << endl;
    }
};

class JpegFile : public File{
public:
    JpegFile(string name) {
        fname = name;
    }
    void display(int dept) {
        for (int i=0; i<dept; i++) {
            cout << "-";
        }
        cout << fname << endl;
    }
};

class Folder: public File {
private:
    vector<File*> files;
public:
    Folder(string name) {
       fname = name; 
    }
    void add(File* f) {
        files.push_back(f);
    }

    void display(int dept) {
        for (int i=0; i<dept; i++) {
            cout << "-";
        }
        cout << fname << endl;
        for(vector<File*>::iterator iter=files.begin(); iter!=files.end(); iter++) {
            (*iter)->display(dept+1);
        }
    }
};



int main(int argc, char** argv) {
    Folder* folder = new Folder("directory1");
    folder->add(new TxtFile("1.txt"));
    folder->add(new JpegFile("hmccb.jpeg"));
    folder->add(new MovFile("yellow.rmvb"));

    Folder* subdir = new Folder("subdir2");
    subdir->add(new TxtFile("2.txt"));
    subdir->add(new JpegFile("another.jpeg"));
    folder->add(subdir);

    folder->display(0);
    
}
